define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'category_income/index' + location.search,
                    add_url: 'category_income/add',
                    edit_url: 'category_income/edit',
                    del_url: 'category_income/del',
                    multi_url: 'category_income/multi',
                    import_url: 'category_income/import',
                    table: 'category_income',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'category.name', title: __('门店名称'), operate: 'LIKE'},
                        {field: 'date_year_month', title: __('所属统计年月')},
                        // {field: 'category_id', title: __('Category_id')},
                        {field: 'quan_amount', title: __('Quan_amount'), operate:'BETWEEN'},
                        {field: 'wechat_recharge_amount', title: __('Wechat_recharge_amount'), operate:'BETWEEN'},
                        {field: 'order_pay_amount', title: __('Order_pay_amount'), operate:'BETWEEN'},
                        // {field: 'refund_amount', title: __('Refund_amount'), operate:'BETWEEN'},
                        // {field: 'category.id', title: __('Category.id')},
                        // {field: 'category.pid', title: __('Category.pid')},
                        // {field: 'category.type', title: __('Category.type'), operate: 'LIKE'},
                        // {field: 'category.name', title: __('Category.name'), operate: 'LIKE'},
                        // {field: 'category.nickname', title: __('Category.nickname'), operate: 'LIKE'},
                        // {field: 'category.flag', title: __('Category.flag'), operate:'FIND_IN_SET', formatter: Table.api.formatter.label},
                        // {field: 'category.image', title: __('Category.image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        // {field: 'category.keywords', title: __('Category.keywords'), operate: 'LIKE'},
                        // {field: 'category.description', title: __('Category.description'), operate: 'LIKE'},
                        // {field: 'category.diyname', title: __('Category.diyname'), operate: 'LIKE'},
                        // {field: 'category.createtime', title: __('Category.createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        // {field: 'category.updatetime', title: __('Category.updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        // {field: 'category.weigh', title: __('Category.weigh')},
                        // {field: 'category.status', title: __('Category.status'), operate: 'LIKE', formatter: Table.api.formatter.status},
                        // {field: 'category.dizhi', title: __('Category.dizhi'), operate: 'LIKE'},
                        // {field: 'category.yingye', title: __('Category.yingye'), operate: 'LIKE'},
                        // {field: 'category.user_id', title: __('Category.user_id')},
                        // {field: 'category.xing', title: __('Category.xing'), operate: 'LIKE'},
                        // {field: 'category.price', title: __('Category.price'), operate:'BETWEEN'},
                        // {field: 'category.juli', title: __('Category.juli'), operate: 'LIKE'},
                        // {field: 'category.lng', title: __('Category.lng'), operate: 'LIKE'},
                        // {field: 'category.lat', title: __('Category.lat'), operate: 'LIKE'},
                        // {field: 'category.phone', title: __('Category.phone'), operate: 'LIKE'},
                        // {field: 'category.jiameng_id', title: __('Category.jiameng_id')},
                        // {field: 'category.business_stare_time', title: __('Category.business_stare_time'), operate: 'LIKE'},
                        // {field: 'category.business_end_time', title: __('Category.business_end_time'), operate: 'LIKE'},
                        // {field: 'category.hall_lock_id', title: __('Category.hall_lock_id'), operate: 'LIKE'},
                        // {field: 'category.lock_client_id', title: __('Category.lock_client_id'), operate: 'LIKE'},
                        // {field: 'category.lock_client_secret', title: __('Category.lock_client_secret'), operate: 'LIKE'},
                        // {field: 'category.lock_username', title: __('Category.lock_username'), operate: 'LIKE'},
                        // {field: 'category.lock_password', title: __('Category.lock_password'), operate: 'LIKE'},
                        // {field: 'category.message_name', title: __('Category.message_name'), operate: 'LIKE'},
                        // {field: 'category.message_secret', title: __('Category.message_secret'), operate: 'LIKE'},
                        // {field: 'category.end_time_min', title: __('Category.end_time_min')},
                        // {field: 'category.end_time_content', title: __('Category.end_time_content'), operate: 'LIKE'},
                        // {field: 'category.wifi_ssid', title: __('Category.wifi_ssid'), operate: 'LIKE'},
                        // {field: 'category.wifi_password', title: __('Category.wifi_password'), operate: 'LIKE'},
                        // {field: 'category.meituan_auth_id', title: __('Category.meituan_auth_id')},
                        // {field: 'category.meituan_open_id', title: __('Category.meituan_open_id'), operate: 'LIKE'},
                        // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
